package com;

import java.util.Set;

import redis.clients.jedis.Jedis;

public class TestString {
	public static void main(String[] args) {
		Jedis jedis = new Jedis("n1");
		try {
			stringTest(jedis);
		} catch (Exception e) {
			e.printStackTrace();
		} finally{
			jedis.close();
		}
	}
	private static void stringTest(Jedis jedis) {
		System.out.println("Server is running: "+jedis.ping());
		jedis.set("key0", "hadoop");
		String value = jedis.get("key0");
		System.out.println(value);
		printAllKey(jedis);
		jedis.del("key0");
		System.out.println(jedis.get("key0"));
		printAllKey(jedis);
	}
	private static void printAllKey(Jedis jedis) {
		Set<String> keys = jedis.keys("*");
		keys.forEach(key -> {
			System.out.println(key);
		});
	}
}
